import router from 'umi/router';

import React from 'react';
import { connect } from 'dva';
import Link from 'umi/link'
import { Table, Button } from 'antd';

const linePath = '/AccountPayment/Payment';
const formPath = '/AccountPayment/PaymentForm';

@connect(({ accountPayment }) => ({ accountPayment }))
class List extends React.Component {
  state = {
  }

  treeview = [
      {
        title: '',
        dataIndex: '_',
        render: (_, { id }) => {
          return <Link to={`${linePath}?id=${id}`}>查看</Link>;
        },
      },
      { title: '付款类型', dataIndex: 'payment_type', },
      { title: '业务伙伴类型', dataIndex: 'partner_type', },
      { title: '状态', dataIndex: 'state', },
      { title: '日期', dataIndex: 'payment_date', },
      { title: '账簿', dataIndex: 'journal_id.name', },
      { title: '目标账簿', dataIndex: 'destination_journal_id.name', },

      { title: '业务伙伴', dataIndex: 'partner_id.name', },
      { title: '总金额', dataIndex: 'amount', },
//      { title: '名称', dataIndex: 'name', },
//      { title: '发票', dataIndex: 'invoice_ids', },
//      { title: '凭证行', dataIndex: 'move_line_ids', },
  ]

  async componentDidMount() {
    const { dispatch } = this.props;
    dispatch({
      type: 'accountPayment/search',
      payload: {domain:[['payment_type','=','inbound']], },

    });
  }


  goto_createForm() {
      router.push(formPath);
  }


  render() {
    const { accountPayment: { recordsList } } = this.props;

    return (
      <div>
        <div size="large" title='说明' style={{ marginBottom: 32 }}>
          <div>这里是收款单，使用 payment 模型</div>
          <div>payment_type=inbound</div>
        </div>

        <Button onClick={()=>this.goto_createForm()}>新建</Button>
        <Table columns={this.treeview} dataSource={recordsList} rowKey="id" />


      </div>
    );
  }
}

export default List;





